package cn.hf.mychat.controller;

import lombok.Getter;
import org.springframework.http.HttpStatus;

import java.util.HashMap;
import java.util.Map;

/**
 * @author lvbx on 2019/2/16
 */
@Getter
public class BadRequestAlertException extends RuntimeException {
	private static final long serialVersionUID = -2348566486238471030L;

	private final String entityName;

	private final String errorKey;

	private final HttpStatus httpStatus;

	private final Map<String, Object> parameters = new HashMap<>();

	public BadRequestAlertException(String defaultMessage, String entityName,
                                    String errorKey) {
		super(defaultMessage);
		this.entityName = entityName;
		this.errorKey = errorKey;
		this.httpStatus = HttpStatus.BAD_REQUEST;
		parameters.put("message", errorKey);
		parameters.put("params", entityName);
	}
}
